import Vue from 'vue'
import VueRouter from 'vue-router'
// import Login from '../views/login/login.vue'

Vue.use(VueRouter)

const routes = [
  // {
  //   path: '/',
  //   name: 'Home',
  //   component: Home
  // },
  {
    path: '/login', // 路径
    name: 'Login', // 路径名字
    // component: Login,
    // route level code-splitting
    // this generates a separate chunk (about.[hash].js) for this route
    // which is lazy-loaded when the route is visited.
    // 懒加载
    // 只有访问这个路由时，这个组件的对应代码才会加载进来
    // 如果不用懒加载，就会出现：一打开这个页面，全部页面（组件）全部加载进来
    component: () => import(/* webpackChunkName: "Login" */ '../views/login/login.vue')
  },
  {
    path: '/', // 主页
    name: 'layout', // 路径名字
    // component: Login,
    // route level code-splitting
    // this generates a separate chunk (about.[hash].js) for this route
    // which is lazy-loaded when the route is visited.
    // 懒加载
    // 只有访问这个路由时，这个组件的对应代码才会加载进来
    // 如果不用懒加载，就会出现：一打开这个页面，全部页面（组件）全部加载进来
    component: () => import(/* webpackChunkName: "layout" */ '../views/layout/layout.vue'),
    children: [
      {
        path: '', // 主页
        name: 'home',
        component: () => import(/* webpackChunkName: "home" */ '../views/home/home.vue')
      },
      {
        path: '/question', // 问答页
        name: 'question',
        component: () => import(/* webpackChunkName: "question" */ '../views/question/question.vue')
      },
      {
        path: '/video', // 视频
        name: 'video',
        component: () => import(/* webpackChunkName: "video" */ '../views/video/video.vue')
      },
      {
        path: '/setting', // 个人中心
        name: 'setting',
        component: () => import(/* webpackChunkName: "setting" */ '../views/setting/setting.vue')
      }
    ]
  },
  {
    path: '/search', // 跳转搜索页
    name: 'search',
    component: () => import(/* webpackChunkName: "search" */ '../views/search/search.vue')
  }
]

const router = new VueRouter({
  routes
})

export default router
